package com.hikvision.ae.common;

import lombok.Data;

/**
 * @author jinjinhui
 * @date 2020/5/14
 */
@Data
public class CommonResult {

    private boolean success;
    private String code;
    private String msg;
    private Object data;

    public CommonResult success(){
        return success(null);
    }

    public CommonResult success(Object data){
        this.success = true;
        this.code = "200";
        this.msg = "成功";
        this.data = data;
        return this;
    }

    public CommonResult fail(){
        return fail("500", "未知异常");
    }

    public CommonResult fail(String code){
        return fail(code, "未知异常");
    }

    public CommonResult fail(String code, String msg){
        this.success = false;
        this.code = code;
        this.msg = msg;
        return this;
    }
}
